require.sync("SignUpTypeEnum");
require.sync("ActivityStatusEnum");
Ext.define('App.view.activity.ActivityWindow', {
	extend : 'App.config.BaseWindow',
	requires : [ 'App.controller.activity.ActivityWindowController'],
	controller : 'activityWindowController',
	xtype : 'activityWindow',
	id : 'activityWindow',
	buttons : [ {
		text : '保存',
		action : 'save'
	}, {
		text : '关闭',
		handler : function() {
			this.up('window').close();
		}
	} ],
	items : [ {
		xtype : 'basewindowform',
		items : [{
			xtype:'hidden',
			name:'id'
		},{
			allowBlank : false,
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
			fieldLabel : '标题',
			name : 'title'
		},{
            fieldLabel : '外观图片',
            name : 'homeImagePath',
            readOnly:true,
            xtype:'textfield',
            hidden:true,
            columnWidth:0.8
        },{
            columnWidth:0.1,
            xtype:'button',
            text:'换图',
            name:'btn1',
            hidden:true,
            listeners:  {
                click:function(me) {
                    var file=Ext.getCmp('activityWindow').down('form').down('[name=homeImages]');
                    file.setVisible(true);
                    file.setDisabled(false);
                    me.setVisible(false);
                }
            }
        },{
            fieldLabel : '外观图片',
            xtype:'filefield',
            name : 'homeImages',
            disabled : false,
            columnWidth:0.8
        },{
            fieldLabel : 'logo',
            name : 'homeImageLogosPath',
            readOnly:true,
            xtype:'textfield',
            hidden:true,
            columnWidth:0.8
        },{
            columnWidth:0.1,
            xtype:'button',
            text:'换图',
            name:'btn2',
            hidden:true,
            listeners:  {
                click:function(me) {
                    var file=Ext.getCmp('activityWindow').down('form').down('[name=homeImageLogos]');
                    file.setVisible(true);
                    file.setDisabled(false);
                    me.setVisible(false);
                }
            }
        },{
            fieldLabel : 'logo',
            xtype:'filefield',
            name : 'homeImageLogos',
            disabled : false,
            columnWidth:0.8
        },{
            allowBlank : false,
            editable: false,
            beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
            fieldLabel : '报名设置',
            name : 'signUpType',
            xtype : 'combo',
            columnWidth:0.51,
            store : Ext.create('Ext.data.Store', {
                fields : [ 'name', 'value' ],
                data : [{
                            'name' : SignUpTypeEnum.SIGN_UP_PEOPLE.getText(),
                            'value' : SignUpTypeEnum.SIGN_UP_PEOPLE.getValue()
                        },{
                            'name' : SignUpTypeEnum.BUY_AMOUNT.getText(),
                            'value' : SignUpTypeEnum.BUY_AMOUNT.getValue()
                        }]
            }),
            queryMode : 'local',
            displayField : 'name',
            valueField : 'value',
            listeners : {
                select:function(combo, record,index){
                    var newvalue=this.value;
                    if(newvalue === SignUpTypeEnum.SIGN_UP_PEOPLE.getValue()){
                        try{
                            var parent=Ext.getCmp('number');
                            parent.setEmptyText('可报名人数');
                            parent.setHidden(false);
                        }catch(ex){
                            Ext.MessageBox.alert("错误","数据加载失败。"+ex);
                        }
                    }else{
                        try{
                            var parent=Ext.getCmp('number');
                            parent.setEmptyText('可报名数量');
                            parent.setHidden(false);
                        }catch(ex){
                            Ext.MessageBox.alert("错误","数据加载失败。"+ex);
                        }
                    }
                }
            }
        },{
            allowBlank : false,
            beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
            fieldLabel : '数量',
            name : 'number',
            id : 'number',
            columnWidth:0.51,
            hidden : true
		},{
			allowBlank : false,
			xtype:"datefield",
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
			fieldLabel : '报名开始时间',
			name : 'enrollBeginTime',
            anchor: '100%',
            format: 'Y-m-d',
            editable: false,
			minValue:new Date,
            submitFormat:'time',
            columnWidth:0.51,
            listeners: {
                select: function (me, value) {
                    me.up('form').getForm().findField('enrollBeginTime').setMinValue(value);
                }
            }
		},{
			allowBlank : false,
            xtype:"datefield",
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
			fieldLabel : '报名结束时间',
			name : 'enrollEndTime',
            anchor: '100%',
            format: 'Y-m-d',
            editable: false,
            columnWidth:0.51,
            submitFormat:'time',
            listeners: {
                select: function (me, value) {
                    me.up('form').getForm().findField('enrollEndTime').setMaxValue(value);
                }
            }
		},{
			allowBlank : false,
			xtype:"datefield",
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
			fieldLabel : '开始时间',
			name : 'beginTime',
            anchor: '100%',
            columnWidth:0.51,
            format: 'Y-m-d',
            editable: false,
			minValue:new Date,
            submitFormat:'time',
            listeners: {
                select: function (me, value) {
                    me.up('form').getForm().findField('endTime').setMinValue(value);
                }
            }
		},{
			allowBlank : false,
            xtype:"datefield",
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
			fieldLabel : '结束时间',
			name : 'endTime',
            anchor: '100%',
            columnWidth:0.51,
            format: 'Y-m-d',
            editable: false,
            submitFormat:'time',
            listeners: {
                select: function (me, value) {
                    me.up('form').getForm().findField('beginTime').setMaxValue(value);
                }
            }
		},{
			allowBlank : false,
			beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
            columnWidth:0.51,
			fieldLabel : '报名费用',
			name : 'price'
        },{
            allowBlank : false,
            editable: false,
            beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
            fieldLabel : '发布状态',
            name : 'activityStatus',
            xtype : 'combo',
            columnWidth:0.51,
            store : Ext.create('Ext.data.Store', {
                fields : [ 'name', 'value' ],
                data : [{
                    'name' : ActivityStatusEnum.PUBLISHED.getText(),
                    'value' : ActivityStatusEnum.PUBLISHED.getValue()
                },{
                    'name' : ActivityStatusEnum.UNPUBLISHED.getText(),
                    'value' : ActivityStatusEnum.UNPUBLISHED.getValue()
                }]
            }),
            queryMode : 'local',
            displayField : 'name',
            valueField : 'value'
		},{
            fieldLabel : "内容",
            beforeLabelTextTpl : [ '<font color=red data-qtip=必填选项>*</font>' ],
            name : 'content',
            allowBlank : false,
            xtype : 'htmleditor',
            columnWidth: 0.90,
            grow : true,
            plugins: [
                Ext.create('App.lib.HtmlEditorExtension')
            ]
		} ]
	} ]
});